<?php
class info_log_adik_asuh extends MY_Controller{
    var $data,
        $limit = 10;    
    function info_log_adik_asuh(){
        parent::MY_Controller();
        $this->data['title'] = "Informasi Log Adik Asuh";
        $this->load->model("m_log_adik_asuh");
        $this->load->model("m_tahun_ajaran");
    }
    function index(){
        $this->get_log_adik_asuh('all',0);
    }
    function search(){
        $url = $this->input->post("url");
        $params = "awal_".date2mysql($this->input->post("awal"));
        $params .= "__akhir_".date2mysql($this->input->post("akhir"));
        if($this->input->post("id_adik_asuh") != ""){
            $params .= "__idAdikAsuh_".$this->input->post("id_adik_asuh");
            $params .= "__AdikAsuh_".$this->input->post("adik_asuh");
        }
        if($this->input->post('tahun_ajaran') != ''){
            $params .= "__idTahunAjaran_".$this->input->post('tahun_ajaran');
        }
        redirect("$url/$params/0/");
    }
    function get_log_adik_asuh($params = 'all',$offset = 0){
        $option = parsing_param2($params);
        $this->data['content'] = "log_adik_asuh/info_log_adik_asuh";
        $this->data['formTitle'] = "Parameter Pencarian";
        $this->data['searchLink'] = "info_log_adik_asuh/get_log_adik_asuh";
        $this->data['listTahunAjaran'] = $this->m_tahun_ajaran->getListTahunAjaran();
        $uri_segment = 4;
        if($offset != 0){
          $offset = $this->uri->segment($uri_segment);  
        }
        $num_rows = $this->m_log_adik_asuh->getCountRows($option);
        $this->data['listLogAdikAsuh'] = $this->m_log_adik_asuh->getListLogAdikAsuh($offset,$this->limit,$option); 
        $config['base_url'] = site_url("info_log_adik_asuh/get_log_adik_asuh")."/".$params;
        $config['uri_segment'] = $uri_segment;
        $config['total_rows'] = $num_rows;
        $config['per_page'] = $this->limit;
        $this->pagination->initialize($config);
        $this->data['pagination'] = $this->pagination->create_links();
        $this->data['offset'] = $offset;
        
        $this->render($this->data);
    }
    function print_log_adik_asuh($params){
        $option = parsing_param2($params);
        $data['listLogAdikAsuh'] = $this->m_log_adik_asuh->getListLogAdikAsuh(NULL,NULL,$option);
        $data['tahunAjaran'] = $this->m_tahun_ajaran->getTahunAjaranById($option['idTahunAjaran']);
        
        $this->load->view('log_adik_asuh/cetak_log_adik_asuh',$data);
    }
    function export_data($params){
        $option = parsing_param2($params);
        $data['data'] = $this->m_log_adik_asuh->getListLogAdikAsuh(NULL,NULL,$option); 
        $data['tahunAjaran'] = $this->m_tahun_ajaran->getTahunAjaranById($option['idTahunAjaran']);
        $data['params'] = $option;
        $this->load->view('log_adik_asuh/cetak_excel',$data);
    }
}
?>
